<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								考试名称：<input type="text" name="name"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="exam:paperdef:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="exam:paperdef:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="exam:paperdef:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "exam/paperdef";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "考试管理",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs " href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs " href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i> 删除</a> ');
		            	actions.push('<a class="btn btn-primary btn-xs " href="#" onclick="looktpl(\'' + row.id + '\')"><i class="fa fa-eye"></i> 试卷模板</a> ');
 		            	actions.push('<a class="btn btn-warning btn-xs " href="#" onclick="makepaper(\'' + row.id + '\')"><i class="fa fa-eye"></i> 生成试卷</a> ');
 		            	/*		            	actions.push('<a class="btn btn-danger btn-xs " href="#" onclick="delpaper(\'' + row.id + '\')"><i class="fa fa-eye"></i> 删除试卷</a> '); 
                        actions.push('<a class="btn btn-info btn-xs " href="#" onclick="lookexam(\'' + row.id + '\')"><i class="fa fa-eye"></i> 考试详情</a> ');*/
						return actions.join('');
		            }
		        },
				/* {
					field : 'id', 
					title : '试卷编号'
				}, */
				{
					field : 'name', 
					title : '试卷名称',
					sortable: true
				},				
				{
					field : 'remark', 
					title : '试卷说明',
					sortable: true
				},
				/* {
					field : 'cid', 
					title : '试卷类别',
					sortable: true
				}, */
				{
					field : 'status', 
					title : '试卷状态',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >开放</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >关闭</a>';
						return actions;
					}
				},
				{
					field : 'starttime', 
					title : '开始时间',
					sortable: true
				},
				{
					field : 'endtime', 
					title : '结束时间',
					sortable: true
				},
				{
					field : 'duration', 
					title : '考试时长(分钟)'
				},
				{
					field : 'nojj', 
					title : '禁止交卷时长'
				},
				{
					field : 'totalScore', 
					title : '卷面总分',
					sortable: true
				},
				{
					field : 'passScore', 
					title : '及格分数',
					sortable: true
				},
/* 				{
					field : 'questionOrder', 
					title : '试题顺序',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >随机</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >原始</a>';
						return actions;
					}
				}, */
				{
					field : 'papertype', 
					title : '试卷类型',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >随机</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >固定</a>';
						return actions;
					}
				}
				/* ,{
					field : 'showkey', 
					title : '公布答案',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >是</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >否</a>';
						return actions;
					}
				}, */
				/* {
					field : 'showmode', 
					title : '显示形式',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >单题</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >整卷</a>';
						return actions;
					}
				}, */
				/* {
					field : 'isenc', 
					title : '是否加密试卷',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >是</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >否</a>';
						return actions;
					}
				},
				{
					field : 'kstype', 
					title : '考试任务类型',
					formatter: function(value, row, index) {
						var actions ;
						if(value==1)  actions='<a class="btn btn-success btn-xs " href="#" >正式</a> ';
						else if(value==2) actions='<a class="btn btn-warning btn-xs " href="#" >模拟</a>';
						else actions='<a class="btn btn-info btn-xs " href="#" >自测</a>';
						return actions;
					}
				},
				{
					field : 'restip', 
					title : '是否限制考场',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >是</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >否</a>';
						return actions;
					}
				},
				{
					field : 'resttime', 
					title : '是否统一交卷时间',
					formatter: function(value, row, index) {
						var actions ;
						if(value)  actions='<a class="btn btn-success btn-xs " href="#" >是</a> ';
						else actions='<a class="btn btn-danger btn-xs " href="#" >否</a>';
						return actions;
					}
				} */
				
				/* {
					field : 'data', 
					title : '试卷模板',
					sortable: true
				}, */

		        ]
            };
            $.table.init(options);
        });
function looktpl(id){
	$.modal.openTab("试卷模板", ctx + "exam/papertpl/"+id);
} 
function lookexam(id){
	$.modal.openTab("考试详情", ctx + "exam/exarrange/"+id);
}
function makepaper(id){
	$.modal.openTab("生成试卷", ctx + "exam/exarrange/makep/"+id);
}
function delpaper(id){
	$.modal.confirm("删除有风险！！！您确定删除当前考试的所有考生试卷吗？", function() {
        var url = ctx + "exam/exarrange/delp/"+id;
       	$.operate.get(url);
	});
}
    </script>
</body>
</html>